package com.chaihu.common.service.impl;

import com.chaihu.bean.dto.user.UserDto;
import com.chaihu.bean.in.user.userinfo.QueryUserIn;
import com.chaihu.bean.out.user.userinfo.QueryUserOut;
import com.chaihu.bean.result.ResponseResult;
import com.chaihu.common.dao.UserDao;
import com.chaihu.intf.common.QueryUserInfoService;
//import lombok.extern.slf4j.Slf4j;
import com.chaihu.intf.icommon.BaseService;
import com.chaihu.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//@Slf4j
@RestController
//@Service
public class QueryUserInfoServiceImpl extends BaseService<ResponseResult<QueryUserOut>, QueryUserIn> implements QueryUserInfoService {
    @Autowired
    private UserDao userDao;

    @Override
    public ResponseResult<QueryUserOut> checkHandle(ResponseResult<QueryUserOut> responseResult, QueryUserIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<QueryUserOut> doHandle(ResponseResult<QueryUserOut> responseResult, QueryUserIn in) {
        List<UserDto> users = userDao.selectRaw();
        users.forEach(System.out::println);
        List<QueryUserOut> queryUserOuts = BeanConvertUtil.covertBeanList(users, QueryUserOut.class);

        responseResult.setData(queryUserOuts.get(0));
        return responseResult;
    }

    @Override
    public ResponseResult<QueryUserOut> respHandle(ResponseResult<QueryUserOut> responseResult, QueryUserIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<QueryUserOut> queryUser(QueryUserIn in) {
        System.out.println("queryUser");
        ResponseResult<QueryUserOut> result = new ResponseResult<>();
        return this.mainHandle(result,in);
    }
}
